// 修改密码的页面
import Prompt from '@/components/Prompt'
import { checkIsLeave } from '@/components/Prompt/contentChange'
import { PwdViewProps } from '../interface'
import UpdatePasswordView from '@/components/UpdatePassword'
import { forwardRef } from 'react'
import usePwdHook from '../servers/pwdServer'
const PwdView = (props: PwdViewProps, ref: any) => {
	const { oldData, newData, ..._useHook } = usePwdHook(props, ref)
	return (
		<>
			<Prompt
				when={false}
				message={() => {
					return checkIsLeave({
						/**原数据 */
						oldData,
						/**离开时数据 */
						newData: newData,
						msg: '内容已修改，是否保存？',
						okText: '保存',
						onOk: _useHook.toSave,
						saveBtnIsLeave: false,
					})
				}}
			/>
			<UpdatePasswordView
				ref={_useHook.passwordRef}
				isShowRememberNewPwd={props.isShowRememberNewPwd}
				onChange={(formData) => _useHook.onChange(formData)}
				strength={props.strength}
			/>
		</>
	)
}

export default forwardRef(PwdView)
